#include <SFML/Network.hpp>
#include <QString>
#include <QChar>

#ifndef MASSAGESTYPES_H
#define MASSAGESTYPES_H


struct Host {
    sf::IpAddress ip;
    QString name;
    sf::Uint8 plCount;
};

struct plInLobby {
    sf::IpAddress   adr;
    sf::Uint16      port;
    QString         name;

    int             lifetime;
};

struct tankInfo {
    sf::Int8    hp;
    sf::Uint16  x;
    sf::Uint16  y;
    sf::Uint16   alpha;
    sf::Uint16   beta;
    sf::Int16   color;

};

struct shoot {
    sf::Uint16  x;
    sf::Uint16  y;
    sf::Uint16  alpha;

    sf::Int16   color;
    sf::Int16   id;
};


//player info
sf::Packet cr_PlInfo_msg(sf::IpAddress ip, sf::Uint16, QString name);
void open_PlInfo_msg(sf::Packet &pack, sf::IpAddress &ip, sf::Uint16 &port, QString &name);

//server info
sf::Packet cr_ServInfo_msg(QString name, sf::Uint8 plCount);
void open_ServInfo_msg(sf::Packet &pack, QString &name, sf::Uint8 &plCount);

//Are u server request
sf::Packet cr_IsServer_msg();

//name request
sf::Packet cr_Name_msg(sf::IpAddress ip = sf::IpAddress::None, sf::Uint16 port = 0);

//connect request
sf::Packet cr_Connect_msg();

//name request
sf::Packet cr_Ok_msg();

//name request
sf::Packet cr_Go_msg();

//chat message
sf::Packet cr_Chat_msg(sf::IpAddress adr, sf::Uint16 port, QString msg);

//player list msgs
sf::Packet cr_PlListReq_msg();
sf::Packet cr_PlList_msg(std::vector<plInLobby>* list);
void open_PlList_msg(sf::Packet &pack, std::vector<plInLobby>* list);

//id
sf::Packet cr_id_msg(sf::Int16 id);

//TankINdo
sf::Packet cr_Tank_msg(sf::Int8    hp,
                        sf::Uint16  x,
                        sf::Uint16  y,
                        sf::Uint16   alpha,
                        sf::Uint16   beta,
                        sf::Int16   color);
void open_Tank_msg(sf::Packet &pack, tankInfo &tank);

sf::Packet cr_Shoot_msg(sf::Uint16 x, sf::Uint16 y, sf::Uint16 alpha, sf::Int16 color, sf::Int16 id);
void open_Shoot_msg(sf::Packet &pack, shoot &sh);


void open_msg_string(sf::Packet &pack, QString &msg);
void open_msg_adr(sf::Packet &pack, sf::IpAddress &ip, sf::Uint16 &port);

#endif // MASSAGESTYPES_H
